﻿
namespace Liger.Web.UI
{

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Liger.Web.Common;
    using Liger.Web.Common.Extensions;
    using System.ComponentModel;

    public class GridAjaxSettings
    {
        public GridAjaxSettings()
        {
            this.Parms = new Dictionary<string, Func<string>>();
            this.AjaxParms = new Dictionary<string, object>();
            this.SortOrder = "asc";
            //this.PageParmName = "pagenumber";
            //this.PagesizeParmName = "pagesize";
        }

        public bool Enabled
        {
            get
            {
                return !string.IsNullOrEmpty(URL);
            }
        }

      
        /// <summary>
        /// ajax url
        /// </summary>
        public string URL
        {
            get;
            set;
        } 

        /// <summary>
        /// 提交到服务器的参数,可动态，比如 { "OrderID" : CurrentOrderData.OrderID }
        /// </summary>
        public IDictionary<string, Func<string>> Parms
        {
            get;
            private set;
        }

        /// <summary>
        /// 提交到服务器的参数
        /// </summary>
        public IDictionary<string, object> AjaxParms
        {
            get;
            set;
        }

        /// <summary>
        /// 状态名
        /// </summary>
        public string StatusName
        {
            get;
            set;
        }
        /// <summary>
        /// 提交方式
        /// </summary>
        public string Method
        {
            get;
            set;
        }
        /// <summary>
        /// 数据源字段名
        /// </summary>
        public string Root
        {
            get;
            set;
        }

        /// <summary>
        /// 数据源记录数字段名
        /// </summary>
        public string Record
        {
            get;
            set;
        }

        /// <summary>
        /// 页索引参数名，(提交给服务器)
        /// </summary>
        public string PageParmName
        {
            get;
            set;
        }

        /// <summary>
        /// 页记录数参数名，(提交给服务器)
        /// </summary>
        public string PagesizeParmName
        {
            get;
            set;
        }
        /// <summary>
        /// 页排序列名(提交给服务器)
        /// </summary>
        public string SortnameParmName
        {
            get;
            set;
        }
        /// <summary>
        /// 页排序方向(提交给服务器)
        /// </summary>
        public string SortorderParmName
        {
            get;
            set;
        }


        /// <summary>
        /// 页排序列名
        /// </summary>
        public string SortName
        {
            get;
            set;
        }
        /// <summary>
        /// 页排序方向
        /// </summary>
        public string SortOrder
        {
            get;
            set;
        }
    }
}
